/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
//import javax.validation.constraints.NotNull;
//import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "persons")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persons.findAll", query = "SELECT p FROM Persons p"),
    @NamedQuery(name = "Persons.findBySsn", query = "SELECT p FROM Persons p WHERE p.ssn = :ssn"),
    @NamedQuery(name = "Persons.findByLastName", query = "SELECT p FROM Persons p WHERE p.lastName = :lastName"),
    @NamedQuery(name = "Persons.findByFirstName", query = "SELECT p FROM Persons p WHERE p.firstName = :firstName"),
    @NamedQuery(name = "Persons.findBySex", query = "SELECT p FROM Persons p WHERE p.sex = :sex"),
    @NamedQuery(name = "Persons.findByAddress", query = "SELECT p FROM Persons p WHERE p.address = :address"),
    @NamedQuery(name = "Persons.findByCity", query = "SELECT p FROM Persons p WHERE p.city = :city"),
    @NamedQuery(name = "Persons.findByState", query = "SELECT p FROM Persons p WHERE p.state = :state"),
    @NamedQuery(name = "Persons.findByZipCode", query = "SELECT p FROM Persons p WHERE p.zipCode = :zipCode"),
    @NamedQuery(name = "Persons.findByEmailAddress", query = "SELECT p FROM Persons p WHERE p.emailAddress = :emailAddress"),
    @NamedQuery(name = "Persons.findByDateOfBirth", query = "SELECT p FROM Persons p WHERE p.dateOfBirth = :dateOfBirth")})
public class Persons implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    //@NotNull
    @Column(name = "SSN")
    private Integer ssn;
    //@Size(max = 50)
    @Column(name = "Last_Name")
    private String lastName;
    //@Size(max = 50)
    @Column(name = "First_Name")
    private String firstName;
    //@Size(max = 45)
    @Column(name = "Sex")
    private String sex;
    //@Size(max = 100)
    @Column(name = "Address")
    private String address;
    //@Size(max = 50)
    @Column(name = "City")
    private String city;
    //@Size(max = 50)
    @Column(name = "State")
    private String state;
    @Column(name = "Zip_Code")
    private Integer zipCode;
    @Lob
    //@Size(max = 16777215)
    @Column(name = "Telephone")
    private String telephone;
    //@Size(max = 50)
    @Column(name = "Email_Address")
    private String emailAddress;
    @Column(name = "Date_Of_Birth")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfBirth;
    @OneToMany(mappedBy = "ssn")
    private Collection<Users> usersCollection;
    @OneToMany(mappedBy = "ssn")
    private Collection<Managers> managersCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ssn")
    private Collection<Employees> employeesCollection;

    public Persons() {
    }

    public Persons(Integer ssn) {
        this.ssn = ssn;
    }

    public Integer getSsn() {
        return ssn;
    }

    public void setSsn(Integer ssn) {
        this.ssn = ssn;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Integer getZipCode() {
        return zipCode;
    }

    public void setZipCode(Integer zipCode) {
        this.zipCode = zipCode;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    @XmlTransient
    public Collection<Users> getUsersCollection() {
        return usersCollection;
    }

    public void setUsersCollection(Collection<Users> usersCollection) {
        this.usersCollection = usersCollection;
    }

    @XmlTransient
    public Collection<Managers> getManagersCollection() {
        return managersCollection;
    }

    public void setManagersCollection(Collection<Managers> managersCollection) {
        this.managersCollection = managersCollection;
    }

    @XmlTransient
    public Collection<Employees> getEmployeesCollection() {
        return employeesCollection;
    }

    public void setEmployeesCollection(Collection<Employees> employeesCollection) {
        this.employeesCollection = employeesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ssn != null ? ssn.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persons)) {
            return false;
        }
        Persons other = (Persons) object;
        if ((this.ssn == null && other.ssn != null) || (this.ssn != null && !this.ssn.equals(other.ssn))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Persons[ ssn=" + ssn + " ]";
    }
    
}
